/**
 * Sample Skeleton for "Untitled" Controller Class
 * You can copy and paste this code into your favorite IDE
 **/

package br.com.atibrasil.fx.controller;

import java.net.URL;
import java.util.ResourceBundle;

import javafx.application.Platform;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Label;
import javafx.scene.control.ProgressIndicator;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import br.com.atibrasil.businessobject.MenuBusinessObject;
import br.com.atibrasil.fx.aplication.GUISplash;


public class SplashForm
    implements Initializable {

    @FXML //  fx:id="pi"
    private ProgressIndicator pi; // Value injected by FXMLLoader
    
    @FXML //  fx:id="imageView"
    private ImageView imageView; // Value injected by FXMLLoader   
    
    @FXML //  fx:id="txtNomeEmpresa"
    private Label txtNomeEmpresa; // Value injected by FXMLLoader    


    @Override // This method is called by the FXMLLoader when initialization is complete
    public void initialize(URL fxmlFileLocation, ResourceBundle resources) {
        assert pi != null : "fx:id=\"pi\" was not injected: check your FXML file 'Untitled'.";   
		pi.setProgress(-1.0f);
		new Thread(){
			public void run(){
				MenuBusinessObject usuarioBO = new MenuBusinessObject();
				usuarioBO.findAll();
				Platform.runLater(new Runnable() {
				      @Override public void run() {
							GUISplash.close();	
				      }
				    });						
			}
		}.start();	
//		Image imagem = new Image(GUISplash.LOGO);
//		imageView.setImage(imagem);
		txtNomeEmpresa.setText(GUISplash.NOME_EMPRESA);
    } 
}
